﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using LiveChartsCore.Drawing;
using LiveChartsCore.SkiaSharpView.WPF;

namespace TestWpfLiveCharts2
{
    /// <summary>
    /// Window1.xaml 的交互逻辑
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();

            timer = new(TimeSpan.FromSeconds(1), DispatcherPriority.Background, OnTimeTick, this.Dispatcher);
            vm = new MainWindowViewModel();
            this.DataContext = vm;

            timer.Start();
        }

        private System.Drawing.PointF? LastDragPosition;
        private bool started;
        private MainWindowViewModel vm;

        private DispatcherTimer timer;
        private Random random = new(0);

        private void OnTimeTick(object? sender, EventArgs e)
        {
            var rect = vm.Sections[0];
            rect.Xj = random.Next(10);
            rect.Yj = random.Next(10);
        }
    }
}